//
// Created by Luis on 2022/4/14.
//

#ifndef FFMPEG_LYFFMPEG_H
#define FFMPEG_LYFFMPEG_H

#include "LYCallJava.h"
#include "pthread.h"
#include "LYPlaystatus.h"
#include "LYAudio.h"

extern "C"{
    #include "libavformat/avformat.h"
};
class LYFFmpeg {
public:
    LYCallJava *callJava = nullptr;
    const char* url = NULL;
    pthread_t decodeThread;
    LYPlaystatus *playstatus = NULL;
    AVFormatContext *pFormatCtx = NULL;
    LYAudio *audio = NULL;
    pthread_mutex_t seek_mutex;
    int duration = 0;
public:
    LYFFmpeg(LYPlaystatus *playstatus, LYCallJava *callJava, const char *url);
    ~LYFFmpeg();
    void parpared();
    void decodeFFmpegThread();
    void start();
    void pause();
    void resume();

    void setMute(jint mute);
    void setVolume(int percent);

    void seek(jint secds);
};
#endif //FFMPEG_LYFFMPEG_H
